package com.yxinsur.imc.web.controller.business;

import com.yxinsur.imc.business.domain.ImcFundBrokerExpression;
import com.yxinsur.imc.business.form.FundBrokerForm;
import com.yxinsur.imc.business.service.IImcFundBrokerExpressionService;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.core.page.TableDataInfo;
import com.yxinsur.imc.common.enums.BusinessType;
import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 人员口径（暨口径达式配置）Controller
 *
 * @author imc
 * @date 2021-10-29
 */
@RestController
@RequestMapping("/business/fund/broker/expression")
public class ImcFundBrokerExpressionController extends BaseController {
    @Autowired
    private IImcFundBrokerExpressionService imcFundBrokerExpressionService;

    /**
     * 查询人员口径（暨口径达式配置）列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ImcFundBrokerExpression imcFundBrokerExpression) {
        startPage();
        List<ImcFundBrokerExpression> list = imcFundBrokerExpressionService.selectImcFundBrokerExpressionList(imcFundBrokerExpression);
        return getDataTable(list);
    }

    /**
     * 导出人员口径（暨口径达式配置）列表
     */
    @PreAuthorize("@ss.hasPermi('system:expression:export')")
    @Log(title = "人员口径（暨口径达式配置）", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ImcFundBrokerExpression imcFundBrokerExpression) {
        List<ImcFundBrokerExpression> list = imcFundBrokerExpressionService.selectImcFundBrokerExpressionList(imcFundBrokerExpression);
        ExcelUtil<ImcFundBrokerExpression> util = new ExcelUtil<ImcFundBrokerExpression>(ImcFundBrokerExpression.class);
        return util.exportExcel(list, "expression");
    }

    /**
     * 获取人员口径（暨口径达式配置）详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:expression:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfoById(@PathVariable("id") Long id) {
        return AjaxResult.success(imcFundBrokerExpressionService.selectImcFundBrokerExpressionById(id));
    }


    /**
     * 获取基本法配置的人员口径（暨口径达式配置）详细信息
     */
    @ApiOperation("获取基本法配置的人员口径（暨口径达式配置）")
    @GetMapping(value = "/getInfo/{fundId}")
    public AjaxResult getInfo(@PathVariable("fundId") Long fundId) {
        return AjaxResult.success(imcFundBrokerExpressionService.selectImcFundBrokerExpressionByFundId(fundId));
    }

    /**
     * 新增人员口径（暨口径达式配置）
     */
    @ApiOperation("新增人员口径（暨口径达式配置）")
    @Log(title = "新增人员口径（暨口径达式配置）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FundBrokerForm fundBrokerForm) {
        return toAjax(imcFundBrokerExpressionService.insertImcFundBrokerExpression(fundBrokerForm));
    }

    /**
     * 修改人员口径（暨口径达式配置）
     */
    @ApiOperation("修改人员口径（暨口径达式配置）")
    @Log(title = "修改人员口径（暨口径达式配置）", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FundBrokerForm fundBrokerForm) {
        return toAjax(imcFundBrokerExpressionService.updateImcFundBrokerExpression(fundBrokerForm));
    }

    /**
     * 生成&检测口径
     */
    @ApiOperation("人员口径-生成&检测口径")
    @Log(title = "人员口径-生成&检测口径", businessType = BusinessType.INSERT)
    @PutMapping("/check")
    public AjaxResult checkExpenseExpression(@RequestBody FundBrokerForm fundBrokerForm) {
        return this.imcFundBrokerExpressionService.checkExpenseExpression(fundBrokerForm);
    }

    /**
     * 删除人员口径（暨口径达式配置）
     */
    @PreAuthorize("@ss.hasPermi('system:expression:remove')")
    @Log(title = "人员口径（暨口径达式配置）", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(imcFundBrokerExpressionService.deleteImcFundBrokerExpressionByIds(ids));
    }
}
